/*
 * Created on May 24, 2004
 * by Mihai Postelnicu
 * email mihai@code.ro
 *
 *
 */
package ro.gateway.aida.search;

import ro.gateway.aida.utils.LocalisedList;



/**
 * @author Mihai Postelnicu
 * email mihai@code.ro
 */
public class ResultRow extends LocalisedList implements Comparable {
    protected int sortIdx;
    protected boolean sortDesc;
    
    public ResultRow() {
    	sortIdx=0;
    	sortDesc=false;
    }
    
    /**
     * @return Returns the sortIdx.
     */
    public int getSortIdx() {
        return sortIdx;
    }
    /**
     * @param sortIdx The sortIdx to set.
     */
    public void setSortIdx(int sortIdx) {
    	if(this.sortIdx==sortIdx) sortDesc=!sortDesc;
        this.sortIdx = sortIdx;
    }
    
    public ResultCell getSorterCell() {
    	return (ResultCell)get(sortIdx);
    }
    
    public int compareTo(Object o) {
    	ResultRow r=(ResultRow)o;
    	return sortDesc?r.getSorterCell().compareTo(getSorterCell()):getSorterCell().compareTo(r.getSorterCell()); 
    }
	/**
	 * @return Returns the sortDesc.
	 */
	public boolean isSortDesc() {
		return sortDesc;
	}
	/**
	 * @param sortDesc The sortDesc to set.
	 */
	public void setSortDesc(boolean sortDesc) {
		this.sortDesc = sortDesc;
	}
	
	public long getProjectId() {
		if(size()==0) return -1;
		
		ResultCell r=(ResultCell) get(0);
		return r.getProjectId();
	}
}
